/*
https://leetcode-cn.com/problems/single-number-iii/solution/zhi-chu-xian-yi-ci-de-shu-zi-iii-by-leet-4i8e/
 */
public class Solution260 {
    public int[] singleNumber(int[] nums) {
        int x=0;
        for (int num : nums) {
            x=x^num;
        }
        int l=(x==Integer.MIN_VALUE?x:x&(-x));
        int t1=0,t2=0;
        for (int num : nums) {
            if ((num&l)==0){
                t1=t1^num;
            }else{
                t2=t2^num;
            }
        }
        return new int[]{t1,t2};
    }

    public static void main(String[] args) {
        System.out.println(new Solution260().singleNumber(new int[]{1,2,1,3,2,5})[0]);
        System.out.println(new Solution260().singleNumber(new int[]{1,2,1,3,2,5})[1]);
    }
}
